package cn.dkdoo.utils.templateCommon;

import cn.dkdoo.utils.common.PageDataDTO;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Query;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * @author nicky
 * @date 2021/7/6 下午5:43
 */
public interface IDkdRepository<T> /*extends MongoRepository<T,String>*/ {

    T insert(T t);

    List<T> insert(List<T> ts);

    T save(T t);

    List<T> save(List<T> ts);

    T findById(String id, String... fields);

    List<T> findByIds(Collection<String> ids, String... fields);

    Map<String, T> findToMap(Collection<String> ids, String... fields);

    Map<String, T> findToMapGroupSelf(Collection<String> ids, Function<? super T, ? extends String> groupKeyFunction, String... fields);

    int removeById(String id);

    int removeByIds(Collection<String> ids);

    PageDataDTO<T> doPage(Integer pageSize, Integer pageNo, Query query, Sort... sorts);
}
